from functools import wraps
from flask import session,redirect,url_for,g
def login_required(func):
    #保留原函数的元信息
    @wraps(func)
    def wrapper(*args,**kwargs):
        if g.user:
            print("已登录")
            return func(*args,**kwargs)
        else:
            print("请登录")
            return redirect(url_for("auth.login"))
    return wrapper